<?php


namespace App\Http\Controllers\DriverApp;
use App\Enum\CodeEnum;
use http\Env\Response;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
/**
 * Class BaseController
 * @package App\Http\Controllers\DriverApp
 * 基类
 */
class BaseController extends Controller
{
    protected $uid;
  public function __construct(Request $request)
  {
      $token = $request->header('token','');
      if ($token == ''){
          exit(json_encode(['code' => CodeEnum::NO_LOGIN, 'msg' => CodeEnum::message(CodeEnum::NO_LOGIN)]));
      }
      $uid = Utils::GetUserIdByToken($token);
      if (empty($uid) || $uid <= 0) {
          exit(json_encode(['code' => CodeEnum::NO_LOGIN, 'msg' => CodeEnum::message(CodeEnum::NO_LOGIN)]));
      }
      $this->uid = $uid;
  }
}